class_name System, "res://ecs/icons/system.svg"
extends Node

var entity_filter: Array
var world
var system_name: String
var requirements := []  #array like [{ "func": "hp_change", "read": ["C_HP"], "create": [], "modify": ['C_HP'], "distroys": []}]
var tps: float


func _system_init(_world) -> bool:
	world = _world
	return true


func _system_ready() -> void:
	pass


func _system_process(_delta: float) -> void:
	pass


func _system_physics_process(_delta: float) -> void:
	pass


func listen_modify(handler, observable, args):
	if not observable is Array:
		observable = [observable]
	requirements.append(
		{
			"func": handler,
			"read": args,
			"modify": observable,
		}
	)


func listen_create(handler, observable, args):
	if not observable is Array:
		observable = [observable]
	requirements.append(
		{
			"func": handler,
			"read": args,
			"create": observable,
		}
	)


func listen_destroy(handler, observable, args):
	if not observable is Array:
		observable = [observable]
	requirements.append(
		{
			"func": handler,
			"read": args,
			"destroy": observable,
		}
	)
